<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>留言管理</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__ADMIN__css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="__ADMIN__css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__ADMIN__css/animate.min.css" rel="stylesheet">
    <link href="__ADMIN__css/style.min862f.css" rel="stylesheet">
    <link href="__ADMIN__js/plugins/layer/laypage/skin/laypage.css" rel="stylesheet">
    <link href="__ADMIN__js/plugins/layer/skin/layer.css" rel="stylesheet">
    <style>
        #show img{
            border-radius: 50%;
            width: 50px;
            height: 50px;
            vertical-align:middle; /*垂直居中*/
        }
    </style>

</head>

<body class="gray-bg">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>留言管理</h5>
                    <div class="ibox-tools">
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <!--<div class="col-md-2">-->
                            <!--<a href="{:U('Admin/admin/add')}" class="btn btn-outline btn-primary"><i class="fa fa-user-plus"></i>添加管理员</a>-->
                        <!--</div>-->
                        <form name="admin_list" id="admin_list" action="{:U('index')}" method="get">
                            <div class="col-md-3" style="margin-top: 2px">
                                <div class="input-group">
                                    <input type="text" name="title" placeholder="请输入留言昵称" value="{$title}" class="input-sm form-control"> <span class="input-group-btn">
                                            <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                            </div>
                            <!--<div class="col-sm-4">-->
                                <!--<select class="form-control m-b">-->
                                    <!--<option value="">==请选择留言来源==</option>-->
                                    <!--<option value="QQ">QQ</option>-->
                                    <!--<option value="微信">微信</option>-->
                                    <!--<option value="微博">微博</option>-->
                                <!--</select>-->
                            <!--</div>-->
                        </form>
                    </div>

                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>留言来源</th>
                            <th>头像</th>
                            <th>昵称</th>
                            <th>留言内容</th>
                            <th>留言时间</th>
                            <th>审核</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="show">
                        <volist name="list" id="va">
                            <tr>
                                <td>{$va.id}</td>
                                <td>{$va.leaversouce}</td>
                                <td>
                                    <if condition="$va['img'] eq ''">
                                            <img src="/Public/Admin/img/profile_small.jpg"/>
                                        <else />
                                            <img src="/{$va.img}"/>
                                    </if>
                                </td>
                                <td>{$va.name}</td>
                                <td>{$va.content|mb_substr=0,5,'utf-8'}</td>
                                <td>{$va.addtime}</td>
                                <td>
                                    <if condition="($va.audit eq 1)">
                                        <a href="javascript:changeState({$va.id})" id="state{$va.id}" class="btn-sm btn-primary btn-rounded">通过</a>
                                        <else />
                                        <a href="javascript:changeState({$va.id})" id="state{$va.id}" class="btn-sm btn-danger btn-rounded">未过</a>
                                    </if>
                                </td>
                                <td>
                                    <a href="{:U('Admin/Leaver/edit?id='.$va['id'])}" type="button" class="btn-sm btn-primary btn-rounded"><i class="fa fa-edit"></i>修改</a>
                                </td>
                            </tr>
                        </volist>

                        </tbody>
                    </table>
                    <div id="pages" style="text-align: center;">{$page}</div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="__ADMIN__js/jquery.min.js"></script>
<script src="__ADMIN__js/bootstrap.min.js"></script>
<script src="__ADMIN__js/plugins/layer/layer.min.js"></script>
<script src="__ADMIN__js/plugins/layer/laypage/laypage.js"></script>
<script src="__ADMIN__js/common.js"></script>
<script>
//好像很实用的样子，后端的同学再也不用写分页逻辑了。
var title = "{$title}";
laypage({
    cont: 'pages', //容器。值可以传入元素id或原生DOM或jquery对象
    pages: {$pageCount}, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
    skin:'#OOFFFF', //当然，您还可以借助自定义皮肤
    skip:true, //是否显示跳转  类型：boolean  默认值：false()  开启是true(1)
    curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取 //curr 当前页
        var page = location.search.match(/page=(\d+)/);
        return page ? page[1] : 1;
    }(),
    jump: function(e, first){ //触发分页后的回调
        // 用于控制首页。值支持三种类型。 如：first: '首页' 如：first: false，则表示不显示首页项
        if(!first){ //一定要加此判断，否则初始时会无限刷新
            location.href = '?title='+ title +'&page='+e.curr;
        }
    }
});
    function changeState(id){
        var objectState = $("#state" + id);
        $.post("{:U('Admin/Leaver/changeState')}",{id:id},function(data){
            if(data.status > 0){
                console.log(data.status);
                layer.msg(data.msg, {icon: 5, time: 1000, anim:6});
            }else{
                layer.msg(data.msg, {icon: 6, time: 1000, anim:6},function(){
                    window.location.href="{:U('Admin/Leaver/index')}";
                });
            }
        });
    }



</script>
</html>
